package com.yt.user.service;

import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.BeanUtils;
import javax.annotation.Resource;
import com.yt.user.common.config.YmlConfig;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.yt.user.mapper.CustomerPhoneMapper;
import com.yt.user.models.service.ICustomerPhoneService;
import com.yt.user.models.bo.CustomerPhoneSaveBO;
import com.yt.user.models.dto.CustomerPhoneDTO;
import lombok.extern.slf4j.Slf4j;

/**
 * 客户手机号关联关系控制器
 *
 * @author yzz
 * @Date 2025-10-22 09:43:35
 */
@Slf4j
@DubboService
public class CustomerPhoneServiceImpl extends ServiceImpl<CustomerPhoneMapper, CustomerPhoneDTO> implements ICustomerPhoneService{

    @Resource
    private YmlConfig ymlConfig;

    @Override
    public boolean add(CustomerPhoneSaveBO saveBO) {
        log.info("开始处理客户手机号关联关系添加请求: {}", saveBO);
        
        CustomerPhoneDTO dto = new CustomerPhoneDTO();
        // 手动设置字段而不是使用BeanUtils.copyProperties
        dto.setCustomerId(saveBO.getCustomerId());
        dto.setPhone(saveBO.getPhone());
        
        log.info("准备插入数据库的数据: {}", dto);
        // 不再手动设置ID，让数据库自动生成或使用业务主键
        boolean result = this.insert(dto);
        log.info("数据库插入结果: {}", result);
        
        return result;
    }
}